﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autofac;
using Autofac.Configuration;
using Ymatou.ServiceCenter.Domain.IRepositories;

namespace Ymatou.ServiceCenter.Domain
{
    public static class RepositoryHub
    {
        private static readonly IContainer Container;
        static RepositoryHub()
        {
            ContainerBuilder builder = new ContainerBuilder();
            builder.RegisterModule(new ConfigurationSettingsReader("autofac"));
            Container = builder.Build();
        }

        public static IServiceDependencyRepository ServiceDependencyRepository
        {
            get
            {
                return Container.Resolve<IServiceDependencyRepository>();
            }
        }

        public static IServiceMetadataRepository ServiceMetadataRepository
        {
            get
            {
                return Container.Resolve<IServiceMetadataRepository>();
            }
        }

        public static IServiceDependencySamplingRepository ServiceDependencySamplingRepository
        {
            get
            {
                return Container.Resolve<IServiceDependencySamplingRepository>();
            }
        }

        public static IServiceConfigRepository ServiceConfigRepository
        {
            get
            {
                return Container.Resolve<IServiceConfigRepository>();
            }
        }

        public static IRpcClientConfigRepository RpcClientConfigRepository
        {
            get { return Container.Resolve<IRpcClientConfigRepository>(); }
        }

        public static IServicedependencyInfoRepository ServicedependencyInfoRepository
        {
            get { return Container.Resolve<IServicedependencyInfoRepository>(); }
        }
    }
}
